<?php
/*---------------------一、PHP文件引用----------------------------------*/
require_once 'response.php';
require_once 'connect_config.php';
require('../config.php');

/*---------------------二、变量参数定义-------------------------------*/
$status = false;
$msg = '';
$data = array();
$username = $_POST['username'];
if(!$username)
{
	$username = $_GET['username'];	
}

/*---------------------三、数据库连接--------------------------------*/
$conn = mysqli_connect(DB_HOST,DB_USER,DB_PWD,DB_NAME,DB_PORT) or die('数据库连接失败');
$query1 = "select * from mdl_course";
$data1 = mysqli_query($conn, $query1);

if ($data1)
{
	$status = true;
	$msg = '成功';
	$i = 0;
	while($row1 = mysqli_fetch_array($data1))
	{    
        	if($row1['id']==1 || $row1['category'] == 0)
		{//跳过开始的首页"云课堂学习平台"
           		continue;
        	}	
		else
		{	
        	$data[$i]['courseid'] = $row1['id'];
			$data[$i]['coursename'] = $row1['fullname'];
			$data[$i]['summary'] = $row1['summary'];
			$data[$i]['summary'] = strip_tags($data[$i]['summary']);
			$category = $row1['category'];
			$query2 = "select * from mdl_course_categories where id='$category'";
			$data2 = mysqli_query($conn, $query2);
			$row2 = mysqli_fetch_array($data2);
			$data[$i]['category'] = $row2['name'];
			$i++;
		}	
	}
/*	echo Response::json($status,$msg,$data);*/
	foreach($data as $key=>$value)
	{
		if(is_array($value))
		{
			foreach($value as $key1=>$value1)
			{
				echo $key1.': '.$value1.'<br>';
			}
		}
		else
			echo $key.':'.$value.'<br>';
		echo "<br>";
	}
}else{
	$status = false;
	$msg = '数据查询失败';
	$valuse = array(
			$status,
			$msg
	);
	echo json_encode($value,JSON_UNESCAPED_UNICODE);
}
?>



